interface RunFuncOptions {
    [key: string]: (...args: any[]) => any;
}

class MethodApi implements RunFuncOptions {
    [key: string]: any;
    public TestPing(){
        return 'pong';
    }
}


class RPCAPI {
    private instance: RunFuncOptions;

    constructor() {
        this.instance = new MethodApi();
    }

    RunFunc(type_name: keyof RunFuncOptions, args: any[] = []): any {
        if (typeof this.instance[type_name] !== 'function') {
            return { error: { code: -32601, message: 'Method not found' } };
        }
        return { result: this.instance[type_name](...args) };
    }

}

export default new RPCAPI()
